<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/13 0013
 * Time: 下午 1:49
 */
namespace app\admin\controller;
use app\common\controller\Curt;
use think\Db;

class  Userapply extends Curt {
    public function getall()
    {
        $keyword=input('keyword');
        if($keyword){
            $where['a.apply_money|b.username']=['like','%'.$keyword.'%'];//模糊查询or可以一个条件中写多个字段以‘|’分开
        }
        if(input('get.begin') && input('get.end')){
            $where['a.apply_time'] =['between',[strtotime(input('get.begin').' '.'00:00:00'),strtotime(input('get.end').' '.'23:59:59')]];
        }
        if(input('get.begin') && !input('get.end')){
            $where['a.apply_time']=['>=',strtotime(input('get.begin').' '.'00:00:00')];
        }
        if(input('get.end') && !input('get.begin')){
            $where['a.apply_time']=['<=',strtotime(input('get.end').' '.'23:59:59')];
        }
        if(input('reviewed')){
            $where['a.reviewed']=input('reviewed');
        }
        $where['a.status']=1;
        $list = $this->model
            ->alias('a')
            ->join(['ec_user'=>'b'],'a.user_id=b. id','left')
            ->order('id desc')
            ->field('a.*,ec_user.username')
            ->where($where)
            ->paginate();
        $page = $list->render();
        $this->assign('list', $list);
        $this->assign('begin', input('get.begin'));
        $this->assign('end', input('get.end'));
        $this->assign('keywords', $keyword);
        $this->assign('reviewed', input('reviewed'));
        $this->assign('type', input('type'));
        $this->assign('page', $page);
    }


    public function edit()
    {
        $data=$this->request->param();
        $res=Db::name('userapply')->update($data);
        if($data['reviewed']==1){
          $msg="你的提现申请通过审核！";
        }elseif($data['reviewed']==3){
            $msg="你的提现申请被驳回：&nbsp;<br>"."&nbsp;&nbsp;&nbsp;驳回原因：".$res['rebutmsg'];
        }
      $this->addmsg(1,$data['user_id'],"用户提现",$msg);
        if ($res) {
            $this->success('操作成功', $this->fetchconfig['edit_success']);
        } else {
            $this->success('未修改内容', $this->fetchconfig['edit_success']);
        }
    }


}